package com.superquan.selfstudybootmybatis.service;

import com.superquan.selfstudybootmybatis.entity.user.User;
import com.superquan.selfstudybootmybatis.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;

    /**
     * 保存用户信息
     * @param user
     * @return
     */
    public int save(User user){
        return userMapper.save(user);
    }

    /**
     * 根据id删除用户信息
     * @param id
     * @return
     */
    public int deleteById (int id){
        return userMapper.deleteById(id);
    }

    /**
     * 根据id获取用户信息
     * @param id
     * @return
     */
    public User getUserInfo(int id){
        return userMapper.getUserInfo(id);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    public int update(User user){
        return userMapper.update(user);
    }

    /**
     * 查询所有用户信息
     * @return
     */
    public List<User> selectAll(){
        return userMapper.selectAll();
    }
}
